package com.demo.study.structural.d07_proxy;

import java.lang.reflect.Proxy;

/**
 * 代理模式
 *
 * @author Baymax
 * @since 2021/1/17
 */
public class Main {
    public static void main(String[] args) {
        Weapon gun = new Gun();
        gun.setBullet(20);

        Weapon weapon1 = (Weapon) Proxy.newProxyInstance(WeaponProxy.class.getClassLoader(), gun.getClass().getInterfaces(),
                new WeaponProxy(gun));
        weapon1.fire();
    }
}
